<template>
  <el-container>
    <div class="header">
      <div class="title">苏小课直播教学平台</div>
      <div class="user-info">
        <div class="notification">
          <i class="bell-icon">🔔</i>
          <span class="badge">1</span>
        </div>
        <div class="user">您好，{{ userStore.uname }}！</div>
        <div class="actions">
          <a href="#">修改密码</a> |
          <a href="./login.html">退出</a>
        </div>
      </div>
    </div>

    <el-header>
      <div class="breadcrumb-nav">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item @click='navigateTo("teacherHome/home.html")'>首页</el-breadcrumb-item>
          <el-breadcrumb-item @click='navigateTo("teacherClass/teacherClass.html")'>我的班级</el-breadcrumb-item>
          <el-breadcrumb-item>{{ className }}</el-breadcrumb-item>
        </el-breadcrumb>
      </div>
    </el-header>

    <el-main>
      <div class="content-wrapper">
        <div class="class-info">
          <h3>班级信息</h3>
          <p>班级名称: {{ className }}</p>
          <p>入学时间: {{ classStartDate }}</p>
          <p>毕业时间: {{ classEndDate }}</p>
        </div>

        <div class="course-info">
          <h3>课程信息 共 {{ courses.length }} 门课程</h3>
          <div class="course-cards">
            <div class="course-card" v-for="course in courses" :key="course.id">
              <h4>{{ course.name }}</h4>
              <p>授课老师: {{ course.teacher }}</p>
              <p>{{ course.startDate }} 至 {{ course.endDate }}</p>
            </div>
          </div>
        </div>

        <div class="student-info">
          <h3>学生 共 {{ students.length }} 人</h3>
          <el-table :data="students" style="width: 100%" @click='navigateTo("studentDetail/studentDetail.html")'>
            <el-table-column
              prop="rank"
              label="排名"
              width="80"
            ></el-table-column>
            <el-table-column
              prop="name"
              label="姓名"
              width="120"
            ></el-table-column>
            <el-table-column
              prop="studentId"
              label="学号"
              width="120"
            ></el-table-column>
            <el-table-column
              prop="gender"
              label="性别"
              width="80"
            ></el-table-column>
            <el-table-column
              prop="phone"
              label="手机号"
              width="150"
            ></el-table-column>
            <el-table-column
              prop="email"
              label="邮箱"
              width="180"
            ></el-table-column>
            <el-table-column
              v-for="course in courses"
              :key="course.id"
              :prop="course.id"
              :label="course.name"
              width="120"
            ></el-table-column>
            <el-table-column label="操作" width="100">
              <template v-slot="scope">
                <el-button @click="viewStudent(scope.row)" type="text"
                  >查看</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </el-main>
  </el-container>
</template>

<script setup>
import { useUserStore } from "../../store/user.js";
let userStore = useUserStore();
userStore.storeInit();

import { ref } from "vue";
import "element-plus/dist/index.css";
import "../../../public/header.css";
import {
  ElContainer,
  ElHeader,
  ElMain,
  ElBreadcrumb,
  ElBreadcrumbItem,
  ElTable,
  ElTableColumn,
  ElButton,
  ElImage,
} from "element-plus";

const className = ref("2019级会计1班");
const classStartDate = ref("2020-09-20");
const classEndDate = ref("2021-07-10");

const courses = ref([
  {
    id: "course1",
    name: "基础会计",
    teacher: "陈少平",
    startDate: "2021-02-20",
    endDate: "2021-07-20",
  },
  {
    id: "course2",
    name: "税收基础",
    teacher: "陈少平",
    startDate: "2021-02-20",
    endDate: "2021-07-20",
  },
  {
    id: "course3",
    name: "电算化",
    teacher: "陈少平",
    startDate: "2021-02-20",
    endDate: "2021-07-20",
  },
  {
    id: "course4",
    name: "法规",
    teacher: "陈少平",
    startDate: "2021-02-20",
    endDate: "2021-07-20",
  },
  {
    id: "course5",
    name: "企业财务会计",
    teacher: "陈少平",
    startDate: "2021-02-20",
    endDate: "2021-07-20",
  },
]);

const students = ref([
  {
    rank: 1,
    name: "郭丹丹",
    studentId: "210001",
    gender: "女",
    phone: "15100000001",
    email: "123456@qq.com",
    course1: 88,
    course2: 90,
    course3: 89,
    course4: 86,
    course5: 91,
  },
  {
    rank: 2,
    name: "张菲菲",
    studentId: "210002",
    gender: "女",
    phone: "15100000001",
    email: "123456@qq.com",
    course1: 88,
    course2: 90,
    course3: 89,
    course4: 86,
    course5: 91,
  },
  // Add more students as needed
]);

const viewStudent = (student) => {
  alert(`Viewing details for student: ${student.name}`);
};

function navigateTo(page) {
  window.location.href = `/src/pages/${page}`;
}

</script>

<style scoped>
#app {
  font-family: Arial, sans-serif;
  background-color: #f5f5f5;
  padding: 20px;
}

.el-header {
  background-color: #fff;
  padding: 10px;
  border-bottom: 1px solid #ddd;
}

.top-nav {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.breadcrumb-nav {
  padding: 0 20px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background-color: #fff;
  border-bottom: 1px solid #ddd;
}

.header .title {
  font-size: 24px;
  color: #1e90ff;
}

.header .user-info {
  display: flex;
  align-items: center;
}

.header .user-info .notification {
  margin-right: 20px;
  position: relative;
}

.header .user-info .notification .badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background-color: red;
  color: #fff;
  border-radius: 50%;
  padding: 2px 5px;
  font-size: 12px;
}

.header .user-info .user {
  margin-right: 10px;
  color: #333;
}

.header .user-info .actions a {
  margin: 0 5px;
  color: #1e90ff;
  text-decoration: none;
}

.el-main {
  display: flex;
  justify-content: center;
}

.content-wrapper {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.class-info,
.course-info,
.student-info {
  margin-bottom: 20px;
}

.course-cards {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.course-card {
  background-color: #f5f5f5;
  padding: 20px;
  border: 1px solid #ddd;
  border-radius: 8px;
  width: 200px;
  text-align: center;
}

.course-card h4 {
  margin-bottom: 10px;
  color: #333;
}

.course-card p {
  margin: 5px 0;
  color: #666;
}
</style>
